package com.lori.netshop.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lori.netshop.pojo.TbContent;
import com.lori.netshop.service.ContentService;
import com.lori.netshop.util.NetshopResult;

@Controller
public class ContentController {
	@Autowired
	private ContentService contentServiceimp;
	
	@RequestMapping("/get/contents/{categoryId}")
	@ResponseBody
	public NetshopResult getContents(@PathVariable long categoryId){
		try {
			//获得数据
			List<TbContent> contents = contentServiceimp.findContents(categoryId);
			return NetshopResult.ok(contents);
		} catch (Exception e) {
			e.printStackTrace();
			return NetshopResult.build(500, e.toString());
		}
	}
}
